package com.winter.controller;


import com.winter.model.Category;
import com.winter.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;
@Controller
@RequestMapping("/Category")
public class CategoryController {
    @Autowired
    private CategoryService categoryService;
    //添加
    @RequestMapping("/insert")
    public String insertCategory(Category category){
        categoryService.insertCategory(category);
        return "";
    }
    // 查询
    @RequestMapping(value = "/query/{pageNum}/{pageSize}" , produces = {"application/json;charset=UTF-8"})
    public String queryAll(Model model, @PathVariable("pageNum") int pageNum, @PathVariable("pageSize") int pageSize){
        List<Category> categories = categoryService.queryAll( pageNum, pageSize);
        model.addAttribute("list",categories);
        return "";
    }
}
